import request from '../utils/request';
import { stringify } from 'qs';
import { baseServerUrl } from '../utils/Constant';

export async function page(params) {
  return request(`${baseServerUrl}/tms/fixed-assets/page?${stringify(params)}`, {
    method: 'GET',
  });
}

export async function insertOrUpdate(params) {
  const { id } = params;
  let method = 'PUT';
  if (id === 0) {
    method = 'POST';
    delete params['id'];
  }
  return request(`${baseServerUrl}/tms/fixed-assets`, {
    method: method,
    body: {
      ...params,
    },
  });
}

export async function del(params) {
  return request(`${baseServerUrl}/tms/fixed-assets`, {
    method: 'DELETE',
    body: params,
  });
}

export async function logs(params) {
  return request(`${baseServerUrl}/tms/fixed-assets/logs`, {
    method: 'POST',
    body: params,
  });
}

export async function imgs(params) {
  return request(`${baseServerUrl}/tms/fixed-assets/imgs`, {
    method: 'POST',
    body: params,
  });

}
